package com.bjfu.intelligentrecognizeserver.mapper;

import com.bjfu.intelligentrecognizeserver.pojo.entity.*;
import com.bjfu.intelligentrecognizeserver.pojo.vo.KingdomVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SpeciesMapper {
    @Select("select * from species")
    List<SpeciesInfo> getAllSpecies();

    void insertSelectSpecies(SelectSpeciesInfo selectSpeciesInfo);
    /*Integer insertSelectSpecies(SelectSpeciesInfo selectSpeciesInfo);
    * 此时mybatis返回的也只是插入数据的行数，不是id*/

    @Select("select id from species where chinese_name = #{chineseName}")
    Integer getIdByChineseName(String chineseName);

    @Select("select * from kingdom order by kingdom_id")
    List<Kingdom> getKingdom();

    @Select("select phylum_id from phylum where phylum_name = #{name}")
    Integer getMenIdByName(String name);

    @Select("select phylum_name from phylum where kingdom_id = #{parentId}")
    List<String> getMenListByKingdomId(Integer parentId);

    @Select("select class_name from class where phylum_id = #{parentId}")
    List<String> getGangListByMenId(Integer parentId);

    @Select("select class_id from class where class_name = #{name}")
    Integer getGangIdByName(String name);

    @Select("select order_id from `order` where order_name = #{name}")
    Integer getMuIdByName(String name);

    @Select("select order_name from `order` where class_id = #{parentId}")
    List<String> getMuListByGangId(Integer parentId);

    @Select("select family_id from family where family_name = #{name}")
    Integer getKeIdByName(String name);

    @Select("select family_name from family where order_id = #{parentId}")
    List<String> getKeListByMuId(Integer parentId);

    @Select("select * from species where chinese_name = #{speciesName}")
    SpeciesInfo getSpeciesInfoBySpeciesName(String speciesName);


    void insertSelectPhoto(SelectImage selectImage);
    void insertSelectAudio(SelectAudio selectAudio);
}
